/*
* @Author: Josh
* @Date:   2019-01-20 14:42:09
* @Last Modified by:   Administrator
* @Last Modified time: 2019-04-14 19:08:37
*/

'use strict';
require('page/common/nav/index.js');
require('page/common/header/index.js');
require('util/slider/index.js');
require('./index.css');

var navSide        = require('page/common/nav-side/index.js'),
    templateBanner = require('./banner.string'),
    _mall          = require('util/mall.js');

/*轮播图插件的初始化*/
$(function() {
    
    //渲染banner的html
    var bannerHtml = _mall.renderHtml(templateBanner);
    $('.banner-con').html(bannerHtml);
    
    //初始化banner
    var $slider = $('.banner').unslider({
        //引导点
        dots : true
    });
    
    //前一张和后一张
    $('.banner-con .banner-arrow').click(function(){
        //判断点击的按钮是左还是右
        var forward = $(this).hasClass('prev') ? 'prev' : 'next';
        //$slider.data('unslider')返回一个对象，再用方括号形式访问其方法。
        $slider.data('unslider')[forward]();
    });
});